#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> PII;
queue<PII> q;
int cnt[100010];
int kinds;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int t, k, x;
		cin >> t >> k;
		for (int i = 1;i <= k;i++)
		{
			cin >> x;
			q.push({ t,x });
			if (cnt[x]++ == 0)kinds++;
		}
		while (q.size() && q.back().first - q.front().first >= 86400)
		{
			PII tmp = q.front();
			q.pop();
			int z = tmp.second;
			if (cnt[z]-- == 1)kinds--;
		}
		cout << kinds << endl;

	}
	return 0;
}